/**
 * @description sequelize 同步数据库
 */
const InitManager = require('./InitManager');
const args = process.argv.slice(2);
const env = args.indexOf('@env') !== -1 ? args[args.indexOf('@env') + 1] : 'dev';
const is_force = args.includes('@f');

InitManager.loadConfig(env);
const seq = require('./db');

require('../app/model'); //←必须的,要先定义表 才有东西同步的说

seq.sync({force: is_force/*置为true,如果存在定义的表,则会先删除原有的*/}).then(() => {
  console.log('sync ok');
  process.exit()
}).catch(err => {
  console.error('something wrong with sync:\n', err);
});
